<?php defined('PATH') or exit();

class Model_CommentList extends SimpleO {

	private $data = array();
	private $index = -1;

	public function __construct() {
		parent::__construct();
	}

	public function load($_news_id /*$_limit, $_offset*/ ) {
		$this->data = array();
		$this->index = -1;
		$temp = $this->db->query('SELECT * FROM `__archez_comments` WHERE `news_id` = '.$this->db->quote($_news_id).' ORDER BY `time` DESC')->fetchAll();
		foreach ($temp as $key => $value) {
			$this->data[$key] = new Model_Comment();
			foreach ($value as $inner_key => $inner_value) {
				$this->data[$key]->$inner_key = $inner_value;
			}
		}
		if (count($this->data) > 0)
			return true;
		return false;
	}

	public function next() {
		$this->index++;
		if ($this->index >= count($this->data))
			return false;
		return $this->data[$this->index];
	}

	public function isLoaded() {
		if (count($this->data) > 0) {
			return true;
		}
		return false;
	}
}
?>